<?php

/**
 * JobeetUser form.
 *
 * @package    jobeet
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class JobeetUserForm extends BaseJobeetUserForm
{
  public function configure()
  {
	parent::setup();	
   $this->setWidgets(array(
      'id'              => new sfWidgetFormInputHidden(),
      'fio'             => new sfWidgetFormInputText(),
      'number_contract' => new sfWidgetFormInputText(),
      'position'        => new sfWidgetFormInputText(),
      'description'     => new sfWidgetFormTextarea(),
      'address'         => new sfWidgetFormTextarea(),
      'email'           => new sfWidgetFormInputText(),
      'phone'           => new sfWidgetFormInputText(),
      //'picture'         => new sfWidgetFormInputFile()
      //'created_at'      => new sfWidgetFormDateTime(),
      //'updated_at'      => new sfWidgetFormDateTime(),
      'picture'         => new sfWidgetFormInputFileEditable(array(
        'label'  => ' Фото',
        'file_src'  =>'/uploads/'. $this->getObject()->getPicture(),
        'is_image'  => true,
        'edit_mode'  => !$this->isNew(),
        'template'  => '<div>%file%<br/>%input%<br/>%delete%%delete_label%</div>'
      )),  
    ));

    $this->setValidators(array(
      'id'              => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'fio'             => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'number_contract' => new sfValidatorString(array('max_length' => 255)),
      'position'        => new sfValidatorString(array('max_length' => 255)),
      'description'     => new sfValidatorString(array('max_length' => 4000)),
      'address'         => new sfValidatorString(array('max_length' => 4000)),
      'email'           => new sfValidatorString(array('max_length' => 255)),
      'phone'           => new sfValidatorInteger(),
      'picture'         => new sfValidatorFile(array('required'=>$this->isNew(), 'path'=> sfConfig::get('sf_upload_dir'))),
      'picture_delete'  => new sfValidatorPass(),
      //'created_at'      => new sfValidatorDateTime(),
      //'updated_at'      => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('jobeet_user[%s]');

    //$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);


    	unset($this->widgetSchema['created_at']);
	unset($this->widgetSchema['updated_at']);
	unset($this->validatorSchema['created_at']);
	unset($this->validatorSchema['updated_at']);
	
  }
}
